//
//  UIWindow+Extension.m
//  囧途而行
//
//  Created by 杨璟 on 16/5/17.
//  Copyright © 2016年 YSKJ. All rights reserved.
//

#import "UIWindow+Extension.h"
#import "ControllerManger.h"
#import "JTNewFeatureController.h"

@implementation UIWindow (Extension)

- (void)switchRootViewController {
    NSString *key = @"CFBundleShortVersionString";
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    
    if ([currentVersion isEqualToString:lastVersion]) {
        self.rootViewController = [ControllerManger sharedManager].rootVC;
    } else {
        JTNewFeatureController *featureVC = [[JTNewFeatureController alloc] init];
        self.rootViewController = featureVC;
        
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

@end
